Skip to content

Let DockerSandbox keep vendor in a volume for listed folders - #340

Merged
AydinHassan merged 5 commits into
masterfrom
student-packages
Oct 31, 2026
Merged

AydinHassan merged 5 commits into
masterfrom
student-packages

Conversation

@AydinHassan

@AydinHassan AydinHassan commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Fourth task of #336 (student packages), reworked.

  • New DockerSandbox constructor argument vendorVolumes: folder => volume, eg. ['/tmp/php-school/<student id>' => 'php-school-vendor-<student id>-<workshop>-<exercise>']. Runs in a listed folder, or below it, mount the volume at /solution/vendor: read-write for composer, read-only otherwise.
  • Folders not listed, eg. reference solutions or a student's own folder on the CLI, keep vendor/ in the folder as before.
  • Nothing is deleted at the end; the caller picks a name that is kept between verifies.
  • Workshop images need /solution/vendor created with 1777, or the volume is root-owned (already in learn-you-php#117 and php8-appreciate#49).

phpschool.io passes the student's volume and skips composer update when the packages haven't changed. Tested with real Docker: second verify of dependency-heaven uploads in 0.6s instead of 2.7s, and deleting the volume just means the next verify reinstalls from the saved lock.

For task 5: ComposerCheck checks vendor/ exists on the host, which passes only because Docker creates the mount point in the bind-mounted folder.

DockerSandbox puts vendor in a volume for each folder composer installs into. Later runs in that folder mount it read-only, and cleanup() removes the volumes when the verify or run finishes. Workshop images need /solution/vendor, like /composer, so the volume is writable.
The caller lists which folders keep vendor in which volume, so it can stay between verifies. Drops the random volumes and Sandbox::cleanup().
@AydinHassan AydinHassan changed the title Keep composer's vendor folder in a volume on the docker host Let DockerSandbox keep vendor in a volume for listed folders Oct 31, 2026
@AydinHassan
AydinHassan merged commit 03f95bf into master Oct 31, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant